package fr.polichouz.geotracer.sender;

import fr.polichouz.geotracer.shared.AlreadyTakeException;
import fr.polichouz.geotracer.shared.GeotracerService;
import fr.polichouz.geotracer.shared.Logger;
import fr.polichouz.geotracer.shared.SimpleLocation;

/**
 * Implementation of the geotracer service for android client.
 * 
 * @author Yoyo
 */
public class GeotracerServiceAndroidImpl implements GeotracerService {
    
    /** Application TAG */
    private static final String TAG = "GeoTracer-Sender";
    
    /** Single class instance (Singleton) */
    private static GeotracerServiceAndroidImpl INSTANCE;
    
    /**
     * Get the class instance.
     * @return
     */
    public static synchronized GeotracerServiceAndroidImpl get() {
	
	if (INSTANCE == null) {
	    INSTANCE = new GeotracerServiceAndroidImpl();
	}
	return INSTANCE;
    }
    
    /** Location sender */
    private Sender sender;
    
    /** Logger */
    private Logger log;
    
    /**
     * Private constructor.
     */
    private GeotracerServiceAndroidImpl() {
	
	log = new AndroidLogger(TAG);
	sender = SenderForServletFactory.get(log).make();
	
	log.info("new service");
    }

    /**
     * @see fr.polichouz.geotracer.shared.GeotracerService
     * #createAccount(java.lang.String, java.lang.String)
     */
    @Override
    public void createAccount(String username, String password)
	    throws AlreadyTakeException, IllegalArgumentException {
	
	// TODO Write this method.
    }

    /**
     * @see fr.polichouz.geotracer.shared.GeotracerService
     * #updateLocation(fr.polichouz.geotracer.shared.SimpleLocation, 
     * java.lang.String, java.lang.String)
     */
    @Override
    public void updateLocation(SimpleLocation location, String username,
	    String password) {
	
	sender.sendUpdateLocation(location, username, password);
    }

    /**
     * @see fr.polichouz.geotracer.shared.GeotracerService
     * #getLocation(java.lang.String, java.lang.String)
     */
    @Override
    public SimpleLocation getLocation(String username, String password) {
	
	// TODO Write this method.
	
	return null;
    }

}
